<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"><!--edge浏览器H5兼容设置-->
    <meta name="renderer" content="webkit"/><!--360浏览器H5兼容设置-->
    <title>用户主页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--导入核心文件-->
    <script src="../bootstrap3/jquery-1.9.1.min.js"></script>
    <script src="../bootstrap3/js/bootstrap.js"></script>
    <script src="../bootstrap3/js/holder.js"></script>
    <link href="../bootstrap3/css/bootstrap.css" rel="stylesheet" type="text/css">
    <!-- 字体图标 -->
    <link rel="stylesheet" href="../bootstrap3/font-awesome-4.7.0/css/font-awesome.css"/>
    <link rel="stylesheet" type="text/css" href="../css/layout.css"/>
    <link rel="stylesheet" type="text/css" href="../css/top.css"/>
    <link rel="stylesheet" type="text/css" href="../css/footer.css"/>
    <!--zTree 资源-->
    <link href="https://cdn.bootcss.com/zTree.v3/3.5.33/css/zTreeStyle/zTreeStyle.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/zTree.v3/3.5.33/js/jquery.ztree.core.min.js"></script>
    <!--页签图标-->
    <link rel="shortcut icon" href="../images/ico/favicon.ico"/>
    <!--城市区划-->
    <!--<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>-->
    <!--我的工具-->
    <script src="../common/LinsCommon.js" type="text/javascript" charset="utf-8"></script>
</head>
<style>
    .trg {
        width: 0;
        height: 0;
        border-left: 3px solid transparent;
        border-right: 3px solid transparent;
        border-top: 6px solid black;
        position: absolute;
        left: 181px;
        top: 8px;
    }

    .org-select {
        cursor: default;
        z-index: -1;
        width: 200px;
    }
</style>
<body>
<div class="container" style="width: 100%;height: 100%;">
    <div class="col-md-10" style="width: 100%;height: 100%;">
        <div class="panel panel-default" style="background: blanchedalmond">
            <ul class="nav nav-tabs">
                <li class="active"><a href="index.html">我的文件</a></li>
                <li><a href="myshare.html">我的共享</a></li>
                <li><a href="share.html">别人共享</a></li>
                <li><a href="password.html">修改密码</a></li>
                <li><a href="login.html" onclick="logout()">注销登录</a></li>
            </ul>
            <div class="panel-body">
                <div style="margin-bottom:10px;">当前位置：
                    <input id="showUrl" type="text" disabled style="width: 700px" class="btn btn-default"
                           data-dismiss="modal"/>
                    <input type="button" value="上一级" id="up" class="btn btn-default" data-dismiss="modal"
                           onclick="goBack() ">
                </div>
                <form id="searchForm">
                    <div style="margin-bottom:10px;">模糊搜索：
                        <input placeholder="请输入文件名" id="search" type="text" style="width: 500px"
                               class="btn btn-default" data-dismiss="modal"/>
                        <div id="suggestionList"></div>
                        <input type="button" value="搜索" onclick="searchF()" class="btn btn-default"
                               data-dismiss="modal">
                        <input type="reset" value="重置" onclick="showAList()" class="btn btn-default" data-dismiss="modal">
                        检索子文件夹：<input type="checkbox" name="zi" value="true"/>
                    </div>
                </form>
                <input type="hidden" id="temp" value="">
                <input type="hidden" id="fidTemp" value="">
                <button id="invertSelection" onclick="invertSelection()" class="btn btn-default">全选</button>
                <button id="delSelected" onclick="delSelected()" style="display: none" class="btn btn-default">删除选定</button>
                <!--<input type="hidden" id="tempMoveFileValue" value="">-->
                <table class="table table-striped">
                    <caption>网络硬盘</caption>
                    <thead>
                    <tr>
                        <th>选择</th>
                        <th>文件名</th>
                        <th>文件大小</th>
                        <th>上传时间</th>
                        <th>文件类型</th>
                        <th>文件路径</th>
                        <th>共享状态</th>
                        <th colspan="3">操作</th>
                    </tr>
                    </thead>
                    <tbody id="address-list">
                    </tbody>
                </table>
                <!-- 删除提示框 -->
                <div class="modal fade" id="delcfmModel">
                    <div class="modal-dialog">
                        <div class="modal-content message_align">
                            <div class="modal-header">
                                <h4 class="modal-title">确认信息</h4>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                        aria-hidden="true">×</span></button>
                            </div>
                            <div class="modal-body">
                                <p id="delcfmMsg">您确认要删除吗？</p>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <a class="btn btn-success" data-dismiss="modal" id="btnOkDelete"
                                   onclick="doDel()">确定</a>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
                <!-- 下载提示框 -->
                <div class="modal fade" id="downloadModel">
                    <div class="modal-dialog">
                        <div class="modal-content message_align">
                            <div class="modal-header">
                                <h4 class="modal-title">确认信息</h4>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                        aria-hidden="true">×</span></button>
                            </div>
                            <div class="modal-body">
                                <p id="downloadMsg">您确认要下载吗？</p>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <a class="btn btn-success" data-dismiss="modal" id="btnOkDownload"
                                   onclick="fileDownload()">确定</a>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal-dialog -->
                </div><!-- /.modal -->
                <!--移动文件-->
                <div class="modal fade" id="moveModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                    &times;
                                </button>
                                <h4 class="modal-title">
                                    移动文件
                                </h4>
                            </div>
                            <div class="modal-body" style="height:auto">
                                <div style="position: relative;top: -102px;margin:90px;left: -101px;">
                                    <input id="orgName" class="org-select" onclick="showTree()" readonly>
                                    <i class="trg" style="position: absolute;"></i>
                                    <input id="orgCode" type="hidden" name="orgCode"/>
                                    <div class="ztree"
                                         style="display:none; position: absolute;border:1px solid #4aa5ff;width:200px;">
                                        <ul id="treeTemp"></ul>
                                    </div>
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                </button>
                                <button type="button" class="btn btn-primary submit" onclick="moveFileSubmit()">
                                    提交更改
                                </button>
                            </div>
                        </div><!-- /.modal-content -->
                    </div><!-- /.modal -->
                </div>
                <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">新建文件夹</button>
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
                     aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                    &times;
                                </button>
                                <h4 class="modal-title" id="myModalLabel">
                                    新建文件夹
                                </h4>
                            </div>
                            <div class="modal-body">
                                输入文件夹名称：<input type="text" name="fname">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                </button>
                                <button type="button" class="btn btn-primary" data-dismiss="modal"
                                        onclick="saveFloder()">
                                    提交
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                <!--重命名-->
                <div class="modal fade" id="renameModal" tabindex="-1" role="dialog" aria-labelledby="renameModalLabel"
                     aria-hidden="true">
                    <div class="modal-dialog">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                    &times;
                                </button>
                                <h4 class="modal-title" id="renameModalLabel">
                                    文件重命名
                                </h4>
                            </div>
                            <div class="modal-body">
                                输入文件新名称：<input type="text" name="rename" placeholder="不需要填文件后缀">
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                </button>
                                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="rename()">
                                    提交
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div>
                <form id="form-change-avatar" class="form-horizontal" role="form">
                    <div class="form-group">
                        <div class="clearfix"></div>
                        <div class="col-md-offset-2 col-md-4">
                            <input type="file" name="file" multiple="multiple">
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <input onclick="upload()" type="button" class="btn btn-primary" value="上传"/>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    let moveParamMap = new Map();


    //初始化
    /*$(document).ready(function () {
            showAList();
            ws();
        });*/
    //初始化jquery简写
    $(function () {
        showAList();
        // ws();
        monitorSelected();
        // apply('', ''); //zry模拟假数据
    })

    function ws() {
        //判断浏览器是否支持WebSocket
        const supportsWebSockets = 'WebSocket' in window || 'MozWebSocket' in window;
        if (supportsWebSockets) {
            //建立WebSocket连接（ip地址换成自己主机ip）
            const ws = new WebSocket(wsBasePath+"/ws");
            ws.onopen = function () {
                //当WebSocket创建成功时，触发onopen事件
                console.log("websocket连接成功");
                //ws.send("hello"); //将消息发送到服务端
                ws.send(
                    /*JSON.stringify({
                        symbols: "['00700.hk]",
                        command:0,
                        version:'1.0.0',
                        token:'szfiu',
                        heartBeat:'heartBeat'
                    })*/

                    JSON.stringify({
                        MyName: 'index'
                    })
                );
            }
            ws.onmessage = function (e) {
                //当客户端收到服务端发来的消息时，触发onmessage事件，参数e.data包含server传递过来的数据
                alert(e.data);
                /*if (e.data.indexOf('禁用')){
                    location.href = "login.html";
                }*/
            }
            ws.onclose = function (e) {
                //当客户端收到服务端发送的关闭连接请求时，触发onclose事件
                console.log("websocket已断开");
            }
            ws.onerror = function (e) {
                //如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
                console.log("websocket发生错误" + e);
            }
        } else {
            // layer.alert("您的浏览器不支持 WebSocket!");
            alert("您的浏览器不支持WebSocket!");
        }
    }

    // 全选
    let selectAll = function() {
        $("input[type='checkbox']").prop("checked", true);
    };

    // 全不选
    let deselectAll = function() {
        $("input[type='checkbox']").prop("checked", false);
    };

    var selected = false;
    // 反选
    let invertSelection = function() {

        if (selected){
            $("#invertSelection").text("全选")
        }else{
            $("#invertSelection").text("全不选")
        }
        selected = !selected
        // $("input[type='checkbox']").each(function() {
        //     $(this).prop("checked", !$(this).is(":checked"));
        // });
        if (selected) {
            $("input[type='checkbox']").each(function () {
                $(this).prop("checked", true);
            })
        }else{
            $("input[type='checkbox']").each(function () {
                $(this).prop("checked", false);
            })
        }
        //判断是否显示
        if($("#delSelected").is(":visible")) {
            $("#delSelected").hide();
        } else {
            $("#delSelected").show();
        }
    };

    // 获取选中的值
    let getSelected = function() {
        var selected = [];
        $("input[type='checkbox']:checked").each(function() {
            selected.push($(this).val());
        });
        alert("选中的值：" + selected.join(", "));
    };

    //监听多选框
    let monitorSelected = function (){
        $('input[type=checkbox]').on('click', function() {
            alert("111")
            if ($('input[type=checkbox]:checked').length > 1) {
                $('#delSelected').show();
            } else {
                $('#delSelected').hide();
            }
        });
        //点击删除按钮后，取消所有勾选，并继续隐藏删除按钮
        $('#delSelected').on('click', function() {
            $('input[type=checkbox]:checked').each(function() {
                $(this).prop('checked', false);
            });
            $('#deleteButton').hide();
        });
    }

    // 删除选中的项
    let delSelected = function() {
        let items = [];
        $("input[type='checkbox']:checked").each(function() {
            items.push($(this).val());
        });
        if (items.length>0){
            $.ajax({
                url: netBasePath+"/fileList/delete",
                type: "POST",
                data: { fids: items },
                success: function(response) {
                    alert(response.data);
                }
            });
        }

    };

    //联想搜索
    $("#search").keyup(function() {
        let keyword = $(this).val();
        if (keyword.length >= 2) { // 设定关键字长度至少为2
            $.ajax({
                url: netBasePath+"/search/suggest",
                type: "GET",
                data: { keyword: keyword },
                success: function(response) {
                    // 根据返回的结果更新展示列表
                    $("#suggestionList").empty();
                    $.each(response.data, function(index, item) {
                        $("#suggestionList").append("<div onclick='searchItemClick(this)'>" + item + "</div>");
                    });
                }
            });
        } else {
            $("#suggestionList").empty(); // 清空展示列表
        }
    });

    //联想选项单击选择
    function searchItemClick(param){
        $("#search").val(param.innerHTML);
        $("#suggestionList").empty();
    }

    //执行删除
    function doDel() {
        let fid = $("#fidTemp").val();
        if (!fid){
            alert("fid不存在")
        }
        $.ajax({
            url: netBasePath+"/file/delete",
            type: "POST",
            // dataType: "JSON",
            data:{fid:fid},
            success: function (json) {
                if (json.code == 200) {
                    showAList();
                } else {
                    alert("删除失败！" + json.msg);
                }
            },
            error: error
        });
    }

    function logout() {
        $.ajax({
            url: netBasePath+"/login/logout",
            type: "POST",
            data: new FormData($("#form-change-avatar")[0]),
            dataType: "JSON",
            processData: false, // 关闭processData处理数据
            contentType: false, // 关闭contentType发送数据的格式
            success: function (json) {
                if (json.code == 200) {
                    location.href = "login.html";
                } else {
                    alert("登出失败！" + json.msg);
                }
            },
            error: error
        });
    }

    function searchF() {
        //拼条件，查列表
        let url = $("#showUrl").val();
        let keyword = $("#search").val();
        let zi = $("input[name='zi']:checked").val();
        if (null == zi) zi = false;
        showAList(url,keyword,zi);
    }

    function upload() {
        const parUrl = $("#showUrl").val();
        if (parUrl) {
            $.ajax({
                url: netBasePath+"/file/upload?parUrl=" + parUrl,
                type: "POST",
                data: new FormData($("#form-change-avatar")[0]),
                dataType: "JSON",
                processData: false, // 关闭processData处理数据
                contentType: false, // 关闭contentType发送数据的格式
                success: function (json) {
                    if (json.code == 200) {
                        inFloder("文件夹", parUrl);
                        alert("上传成功！")
                    } else {
                        alert("上传失败！" + json.msg);
                    }
                },
                error: error
            });
        } else {
            alert("parUrl为空!请联系管理员！")//
        }

    }

    function showAList(url,keyword,selectZi) {
        if(!url){
            url=$("#showUrl").val();
            if (''===url) url="/home"
        }

        $("#address-list").empty();
        let token = localStorage.getItem('token');
        $.ajax({
            url: netBasePath+"/file/findList",
            type: "POST",
            dataType: "JSON",
            contentType: 'application/json',
            // headers: getToken,
            headers: {
                'satoken':token
            },
            sync: false,
            data: JSON.stringify({
                parUrl: url,
                keyword:keyword,
                selectZi:selectZi
            }),
            success: function(json) {
                if (json.code == 200) {
                    apply(json, url);
                    // getJsonTree();
                } else {
                    requestOkButCodeError(json);
                }
            },
            error:error
        });
    }

    function fileDownload() {
        let fid = $("#fidTemp").val();
        if (fid){
            window.location.href = netBasePath+"/file/download?fid="+fid;
        }else {
            alert("文件id为空");
        }
    }

    function saveFloder() {
        const parUrl = $("#showUrl").val();
        const fname = $('input[name="fname"]').val();
        $.ajax({
            // url: '/fileList/saveFloder?fileName=' + fname + '&parUrl=' + parUrl,
            url: netBasePath+'/file/saveFloder',
            type: "POST",
            data: {
                floderName: fname,
                parUrl: parUrl
            },
            headers: {
                'token':localStorage.getItem('token')
            },
            // dataType: "JSON",
            success: function (json) {
                if (json.code == 200) {
                    inFloder("文件夹", parUrl);
                } else {
                    alert(json.msg);
                }
            },
            error: error
        });
    }

    //执行 重命名
    function rename() {
        let fid = $("#fidTemp").val()
        let newName = $('input[name="rename"]').val();
        $.ajax({
            url: netBasePath+'/file/rename',
            type: "POST",
            // dataType: "JSON",
            data: {
                fid: fid,
                newName: newName
            },
            success: function (json) {
                if (json.code == 200) {
                    showAList();
                    // inFloder("文件夹", $("#showUrl").val());
                } else {
                    alert("重命名失败！" + json.msg);
                }
            },
            error: error
        });
    }

    //进入文件夹
    function inFloder(fileType, url) {
        if ("文件夹" === fileType) {
            $("#address-list").empty();
            showAList(url); //刷新列表
        } else {
            /*文件弹框可预览*/
            /*window.location.href = "https://bucket.aoas.top"+url;*/
            window.open(
                `https://bucket.aoas.top` + url,
                "_blank",
                "width=800,height=500,menubar=no,toolbar=no,location=no,status=no,resizable=no"
            )
        }
    }

    //上一级
    function goBack() {
        $("#address-list").empty();
        let url = $('#showUrl').val();
        if (url === "/home") {
            alert("当前已经是根目录！");
        } else {
            url = url.substring(0,url.lastIndexOf("\/"));
            $('#showUrl').val(url); //更新显示
        }
        showAList(url);
    }

    function cacheFid(fid) {
        //不能直接发请求，此时中间还有弹窗确认环节，先将想要操作的fid存起来，在确认框后再取值
        if (typeof fid === "undefined") {
            alert("文件ID is undefined");
        } else if(fid){
            $("#fidTemp").val(fid);
        } else {
            alert("文件ID是空的")
        }
    }

    function apply(json, url) {
        const list = json.data;
        // 模拟数据
        // const list = [{ fid: '1', fileType: '1', url: '1' }, { fid: '1', fileType: '1', url: '1' }, { fid: '1', fileType: '1', url: '1' }, { fid: '1', fileType: '1', url: '1' }];
        // if (list.length == 0) alert("当前目录没有文件");
        if (list) {
            for (let i = 0; i < list.length; i++) {
                let address =
                    `<tr>
                    <td><input type="checkbox" id="'${list[i].id}'" value="'${list[i].id}'"></td>
					<td onclick="inFloder('${list[i].fileType}','${list[i].url}')"> <img id="i" width="80" height="60" src="../images/ico/${list[i].imgUrl}"/> <a href="#">#{filename}</a>  </td>
					<td>#{filesize}</td>
					<td>#{createtime}</td>
					<td>#{filetype}</td>
					<td>#{url}</td>
					<td><a class="btn btn-xs add-del btn-info" onclick="shareButton('${list[i].id}','${list[i].uid}')"> #{share}</a> </td>
					<td><a onclick="cacheFid(#{fid})" class="btn btn-xs add-del btn-info" data-toggle="modal" data-target="#delcfmModel"><span class="fa fa-trash-o"></span> 删除文件</a></td>
					<td><button class="btn btn-xs add-del btn-info" data-toggle="modal" data-target="#moveModal" onclick="moveFile('${list[i].fileName}','${list[i].id}')"><span class="fa fa-home fa-fw"></span> 移动文件</button></td>
					<td><button class="btn btn-xs add-del btn-info" data-toggle="modal" data-target="#renameModal" onclick="cacheFid('${list[i].id}')"><span class="fa fa-pencil fa-fw"></span> 重命名</button></td>
					<td class="show"><a onclick="cacheFid('${list[i].id}')" class="btn btn-xs add-del btn-info" data-toggle="modal" data-target="#downloadModel"><span class="fa fa-camera-retro"></span> 下载文件</a></td>
					</tr>
					`
                //替换
                address = address.replace("#{fid}", list[i].id);
                address = address.replace("#{uid}", list[i].uid);
                address = address.replace("#{filename}", list[i].fileName);
                address = address.replace("#{filesize}", list[i].fileSize);
                address = address.replace("#{createtime}", list[i].createTime);
                address = address.replace("#{share}", list[i].share);
                address = address.replace("#{url}", list[i].url);
                address = address.replace("#{filetype}", list[i].fileType);
                address = address.replace("#{parid}", list[i].parId);
                address = address.replace("#{imgurl}", list[i].imgUrl);
                //放入
                $("#address-list").append(address);
                if ('文件夹' === list[i].fileType) document.getElementsByClassName("show")[i].style.visibility = "hidden";
            }
            $("#showUrl").val(list[0].parUrl)
        } else {
            $("#showUrl").val(url)
        }
    }

    function shareButton(fid, uid) {
        $.ajax({
            url: netBasePath+"/file/changeShare",
            type: "GET",
            data:{fid:fid,uid:uid},
            // dataType: "JSON",
            // async: true,
            success: function (json) {
                if (json.code == 200) {
                    //showAList();  //刷新到首页体验不好，应该根据showUrl刷新到当前页
                    inFloder("文件夹", $("#showUrl").val());
                } else {
                    alert("修改状态异常：" + json.msg);
                }
            },
            error: error
        });//
    }

    //移动文件提交
    function moveFileSubmit() {
        let fileName = moveParamMap.get("fileName");
        let fid = moveParamMap.get("fid");
        let nodeName = moveParamMap.get("nodeName");
        let nodeId = moveParamMap.get("nodeId");

        if (nodeName == null || nodeName == '') {
            alert("确定要移动《" + fileName + "》到《/home》根目录吗？")
            moveParamMap.set('pid', 0);
        } else {
            if (fileName == nodeName) {
                alert("文件夹目录不能移动到自己目录下"); //只针对文件夹限制移动到自己下面
                return false;
            } else {
                alert("确定要移动《" + fileName + "》到《" + nodeName + "》吗？");
            }
        }
        // map.set("treeNodeName",treeNodeName);
        // map.set("treeNodeId",treeNodeId);
        //doMoveFile(map);
        // doMoveFile(paramArray);

        //目标节点id就是pid
        doMove(fid,nodeId);
        $(".submit").attr("data-dismiss", "modal");
    }

    //树状图展示
    const setting = {
        data: {
            simpleData: {
                enable: true
            }
        },
        //回调
        callback: {
            onClick: zTreeOnClick
        },
        view: {
            fontCss: {fontSize: "14px"}
        }
    };

    //
    // paramArray = [];
    function moveFile(fileName, fid) {
        getJsonTree();
        //需要 filename,fid
        //$("#tempMoveFileValue").val(filename);
        // paramArray = [];//放入之前先清空
        // paramArray.push(filename, fid);
        // map.set("filename",filename);
        // map.set("fid",fid);

        moveParamMap.set('fileName',fileName);
        moveParamMap.set('fid',fid);
    }


    //节点点击事件
    function zTreeOnClick(event, treeId, treeNode) {
        moveParamMap.set('nodeName',treeNode.name);
        moveParamMap.set('nodeId',treeNode.id);
        //console.log('当前文件位置：',treeNode.getPath().map(function (node) { return node.name; }).join('-'))
        $('#orgName').val(treeNode.name);
        $('#orgCode').val(treeNode.id);
        hideTree();
        //点击节点即触发请求,这里需要加确定按钮，然后执行doMove
        // doMove(treeNode.name,$("#temp").val());
    }

    //执行移动文件请求
    function doMove(fid,pid) {
        $.ajax({
            url: netBasePath+"/file/move",
            type: "POST",
            // contentType: 'application/json;charset=utf-8',
            // dataType: "JSON",
            // async: true,
            // data: JSON.stringify(param),
            data: {
                fid:fid,
                pid:pid
            },
            success: function (json) {
                if (json.code == 200) {
                    alert("文件移动成功！")
                    //showAList();
                    inFloder("文件夹", $("#showUrl").val());
                } else {
                    alert("文件移动失败：" + json.msg);
                }
            },
            error: error
        });
    }

    //下拉框显示 隐藏
    function showTree() {
        if ($('.ztree').css('display') == 'none') {
            $('.ztree').css('display', 'block');
        } else {
            $('.ztree').css('display', 'none');
        }
        $("body").bind("mousedown", onBodyDownByActionType);
    }

    //改为，文件列表获取成功后，获取树状图
    function getJsonTree() {
        //初始组织树状图
        $.ajax({
            url: netBasePath+"/file/findTree",
            type: "GET",
            headers: getToken,
            // dataType: "JSON",
            // async: true,
            success: function (json) {
                if (json.code == 200) {
                    //放数据
                    $.fn.zTree.init($("#treeTemp"), setting, json.data);
                } else {
                    alert("获取树状图失败！" + json.msg);
                    //location.href = "login.html";
                }
            },
            error: error
        });
    }
    function hideTree() {
        $('.ztree').css('display', 'none');
        $("body").unbind("mousedown", onBodyDownByActionType);
        return false;
    }

    //区域外点击事件
    function onBodyDownByActionType(event) {
        if (event.target.id.indexOf('treeTemp') == -1) {
            if (event.target.id != 'selectDevType') {
                hideTree();
            }
        }
    }
</script>
</body>
</html>